<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>选择车型-去保养-氦修驿站旗下品牌</title>
    <meta name="keywords" content="汽车保养,汽车配件,汽车维修,养车无忧,养车,4S店品质,氦修驿站,丰田保养" />
    <meta name="description" content="100%正品配件,4S店一半价格,先行赔付,闪电送达!线上购买配件,线下提供安装.上万用户的最佳选择!去掉中间环节,直接从源头采购配件!" />
	<link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/css/base.css">
    <link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/css/baoyang.css">
</head>
<body>

    <include file="Public:header" />

    <div id="wrap">
        <h2 class="title">
            我的预约
        </h2>
        <div class="inquiry_list_nav">
            <empty name="_SESSION['user']">
                <div class="inquiry_box">
                    <div class="img_left">
                        <img src="{:C('WEB_URL')}Public/images/phone_inquiries.jpg" alt="">
                    </div>
                    <div class="img_right">
                        <p>手机号码查询订单</p>
                        <div class="phone">
                            <span>手机号码</span><input type="text" name="searchPhone" maxlength="11" autocomplete="off" value=""><a href="javascript:void(0);" id="J_searchGetCode">获取验证码</a></div>
                            <div class="note"><span>短信验证码</span><input type="text" name="searchCode" maxlength="6" autocomplete="off" value=""><a href="javascript:void(0);" id="J_smsCheckBut">查询</a></div>
                        <div class="mt10">若短信异常，请联系客服400-673-0088为您查询</div>
                    </div>
                    <div class="clear"></div>
                </div>
                
                <table class="order_list_table">
                    <thead>
                        <tr>
                            <th>订单号</th>
                            <th>爱车车型</th>
                            <th>安装维修厂</th>
                            <th>订单金额</th>
                            <th>下单时间</th>
                            <th>状态</th>
                        </tr>
                    </thead>
                    <tbody class="empty_data">
                        <tr>
                            <td align="center" colspan="6">请输入手机号码查询订单</td>
                        </tr>

                    </tbody>
                </table>
            <else />
                <table class="order_list_table">
                    <tbody>
                        <tr>
                            <th>订单号</th>
                            <th>爱车车型</th>
                            <th>安装维修厂</th>
                            <th>订单金额</th>
                            <th>下单时间</th>
                            <th>状态</th>
                        </tr>
                        <empty name="order">
                            <tr class="empty_data">
                                <td align="center" colspan="7">您当前暂无预约信息</td>
                            </tr>
                            <tr class="">
                                <td class="paging" colspan="7"></td>
                            </tr>
                        <else />
                            <php>$status=array(1=>'配单中',5=>'待支付',10=>'已确认',15=>'已采购',25=>'发货失败',30=>'已发货',40=>'已收货',50=>装配中,60=>服务完成,100=>'交易关闭');</php>
                            <volist name="order" id="vo">
                                <tr>
                                    <td>{$vo['order_num']}</td>
                                    <td>{$vo['brand_name']} {$vo['model_name']} {$vo['model_pl']} {$vo['model_year']}</td>
                                    <td>{$vo['name']} <br /><span>{$vo['address']}</span></td>
                                    <td>￥{$vo['total_price']}</td>
                                    <td>{$vo['create_time']|date='Y-m-d',###}</td>
                                    <td>
                                        <eq name="vo['status']" value="100">
                                            <span class="btnGray">交易关闭</span>
                                        </eq>
                                        <elt name="vo['pay_type']" value="0">
                                            <a href="{:U('baoyang/alipay')}?order_id={$vo['order_id']}" class="btnBlue" >立即支付</a>
                                        </elt>
                                        <eq name="vo['status']" value="20">
                                            <span class="btnGray">待发货</span>
                                        </eq>
                                        <eq name="vo['status']" value="30">
                                            <a href="javascript:receive({$vo['order_id']});" class="btnBlue">确认收货</a>
                                        </eq>
                                        <eq name="vo['status']" value="40">
                                            <span class="btnGray">已收货</span>
                                        </eq>
                                        <neq name="vo['status']" value="100">
                                        <a href="{:U('comment')}?order_id={$vo['order_id']}" class="btnBlue" id="J_btnComment" <lt name="order['status']" value="40">style="display:none;"</lt> >确认评价</a>
                                        </neq>
                                    </td>
                                </tr>
                            </volist>
                        </empty>
                    </tbody>
                </table>
            </empty>
        </div>
    </div>
    <include file="Public:footer" />
    <include file="Public:loginReg" />
    <script>
    function receive(order_id){
    	if(confirm('是否确认收货?')){
			$.ajax({
                 url:"/baoyang/receive.html",
                 type:"POST",
                 data:{"order_id":order_id},
                 datType:"JSON",
                 success:function(res){
					if(res.status==1){
						window.location.reload();
					}
                 }
             })
    	}
    }
        var searchOrder={
            init:function(){
                var _t=this;
                this.getCodeStatus();

                $("#J_searchGetCode").on("click",function(){
                    var _tt = $(this);

                    if (_tt.hasClass("getCodeGray")) {
                        return false;
                    }

                    var phone=$("input[name='searchPhone']").val();
                    if(!/^(13|15|18|14|17)[0-9]{9}$/.test(phone)){
                        alert("请输入正确的手机号");
                        return false;
                    }
                    _tt.addClass("getCodeGray");
                    $.ajax({
                        url:"/baoyang/searchOrderGetCode.html",
                        type:"POST",
                        data:{"phone":phone},
                        datType:"JSON",
                        success:function(res){
                            if(res.status==1){
                                setCookie("searchOrderMin",60);
                                _t.countDown(_tt);
                            }else{
                                _tt.removeClass("getCodeGray");
                                alert(res['info']);
                            }
                        }
                    })
                });
                $("#J_smsCheckBut").on("click",function(){
                    _t.submitSearch();
                })
                
            },
            submitSearch:function(){
                var phone=$("input[name='searchPhone']").val(),
                    code=$("input[name='searchCode']").val(),
                    _t=this;
                if(!/^(13|15|18|14|17)[0-9]{9}$/.test(phone)){
                    alert("请输入正确的手机号");
                    return false;
                }else if(!/^\d{6}$/.test(code)){
                    alert("短信验证码格式有误！");                    
                    return false;
                }

                $.ajax({
                    url:"/baoyang/getOrderData.html",
                    type:"POST",
                    data:{"code":code},
                    datType:"JSON",
                    success:function(res){
                        if(res.status==1){
                            _t.printOrder(res.data);
                        }else{
                            alert(res.info);
                        }
                    }
                })

            },
            printOrder:function(data){
                var status={1:'配单中',5:'客服确认信息中',10:'已确认',15:'已采购',25:'发货失败',30:'已发货',40:'已收货',50:"装配中",60:"服务完成",100:'交易关闭'},
                    html="",
                    len=data.length,
                    i=0;
                for(;i<len;i++){
                    html+='<tr>'+
                                '<td>'+data[i]['order_num']+'</td>'+
                                '<td>'+data[i]['brand_name']+' '+data[i]['model_name']+' '+data[i]['model_pl']+' '+data[i]['model_year']+'</td>'+
                                '<td>'+data[i]['name']+'<br /><span>'+data[i]['address']+'</span></td>'+
                                '<td>￥'+data[i]['total_price']+'</td>'+
                                '<td>'+status[data[i]['status']]+'</td>'+
                            '</tr>';
                }
                $(".empty_data").html(html).removeClass("empty_data");
            },
            getCodeStatus:function (){
                var min=getCookie("searchOrderMin");
                if(min>0){
                    $("#J_searchGetCode").addClass("getCodeGray");
                    this.countDown($("#J_searchGetCode"));
                }
            },

            //验证码倒计时
            countDown:function (_tt) {
                var _t=this;
                min=getCookie("searchOrderMin")*1-1;
                if (min == 0) {
                    _tt.html("获取验证码");
                    _tt.removeClass("getCodeGray");
                } else {
                    _tt.html(min+"秒后重新获取");
                    setCookie("searchOrderMin",min--);
                    setTimeout(function() {
                        _t.countDown(_tt);
                    },1000)
                }
            }

        }
        searchOrder.init();
    </script>
    

</body>
</html>